package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.TransportTaskEntity;
import com.jinmdz.fmis.mapper.mapper.provider.TransportTaskProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 接运任务表Mapper
 *
 * @author generator
 * @date 2020-03-12 17:08
 */
public interface TransportTaskMapper {

    /**
     * 增加TransportTask
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @InsertProvider(type = TransportTaskProvider.class, method = "insertTransportTask")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertTransportTask(@Param("entity") TransportTaskEntity entity);

    /**
     * 删除TransportTask
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Update(" update transport_task set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForTransportTask(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改TransportTask
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @UpdateProvider(type = TransportTaskProvider.class, method = "updateTransportTask")
    void updateTransportTask(@Param("entity") TransportTaskEntity entity);

    /**
     * 查询TransportTask实体
     *
     * @param id 主键
     * @return TransportTaskEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Select(" select id,deleted,business_code,transport_purpose_code,appointment_time,transport_car_type_code,transport_car_id,transport_car_no,driver_user_id,driver_user_name,driver_user_telephone,transport_place,transport_linkman,transport_telephone,departure_time,return_time,process_state_code,as_empty_car,transport_distance,rule_number,rule_unit,rule_code,rule_remark,remark,random_code,charge_id,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from transport_task where id = #{id} and deleted = 0 limit 1 ")
    TransportTaskEntity getTransportTaskById(@Param("id") Integer id);

    /**
     * 查询TransportTask列表
     *
     * @param entity 数据实体
     * @return TransportTaskEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @SelectProvider(type = TransportTaskProvider.class, method = "listTransportTask")
    ArrayList<TransportTaskEntity> listTransportTask(@Param("entity") TransportTaskEntity entity);
}